﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace AllenalaMente.Games.Blocks
{
    public enum BlockColor
    {
        Blue,
        Green,
        Red,
        Brown,
        Yellow,
        Cyan,
        Magenta,
        Purple,
        TotalColors
    }

    public partial class Block : UserControl
    {
        public int value = 0;

        public Block(int value, BlockColor bcolor)
        {
            InitializeComponent();

            this.value = value;
            textBlock1.Text = value.ToString();

            // Colore Random
            rectangle.Fill = new SolidColorBrush(ConvertBlockColor(bcolor));

            expand.Begin();
        }

        private Color ConvertBlockColor(BlockColor color)
        {
            Color finalColor = Colors.Transparent;
           
            switch (color)
            {
                case BlockColor.Blue:
                    finalColor = Colors.Blue;
                    break;
                case BlockColor.Green:
                    finalColor = Colors.Green;
                    break;
                case BlockColor.Red:
                    finalColor = Colors.Red;
                    break;
                case BlockColor.Brown:
                    finalColor = Colors.Brown;
                    break;
                case BlockColor.Yellow:
                    finalColor = Colors.Yellow;
                    break;
                case BlockColor.Cyan:
                    finalColor = Colors.Cyan;
                    break;
                case BlockColor.Magenta:
                    finalColor = Colors.Magenta;
                    break;
                case BlockColor.Purple:
                    finalColor = Colors.Purple;
                    break;
            }

            return finalColor;
        }
    }
}
